<?php
/**
 * PHP Version 5.2
 *
 * @package    Test
 * @copyright  Copyright (c) 2007-2008 Johannes Trink <johannes.trink@extreme-programmers.com>
 * @license    http://extreme-programmers.com/license
 * @version    $Id$
 */

/**
 * Test loader
 *
 * @package    Test
 * @copyright  Copyright (c) 2007-2008 Johannes Trink <johannes.trink@extreme-programmers.com>
 * @license    http://extreme-programmers.com/license
 * @author     Johannes Trink <johannes.trink@extreme-programmers.com>
 */
class DotHerbert_Test_Loader
{
    /**
     * Get PHPUnit main method
     *
     * @param  string $path
     * @return string
     */
    public static function getMainMethod($path)
    {
        return str_replace(DIRECTORY_SEPARATOR, '_',
                           substr(self::_getRelativePath($path), 0, -4))
             . '::main';
    }

    /**
     * Get relative path
     *
     * @param  string $path
     * @return string
     */
    private static function _getRelativePath($path)
    {
        return substr($path, strrpos($path,
                                     DIRECTORY_SEPARATOR . 'tests'
                                   . DIRECTORY_SEPARATOR) + 7);
    }
}